<?php

namespace apps\admin\models;

use Phalcon\Mvc\Model\Behavior\SoftDelete;
use enums\SystemEnums;

class SystemDic extends \Phalcon\Mvc\Model
{

    /**
     *
     * @var integer
     */
    public $id;

    /**
     *
     * @var string
     */
    public $addtime;

    /**
     *
     * @var string
     */
    public $uptime;

    /**
     *
     * @var integer
     */
    public $delsign;

    /**
     *
     * @var string
     */
    public $descr;

    /**
     *
     * @var string
     */
    public $title;

    /**
     *
     * @var string
     */
    public $key;

    /**
     *
     * @var string
     */
    public $value;

    /**
     *
     * @var integer
     */
    public $valtype;

    /**
     *
     * @var string
     */
    public $kind;

    /**
     * Independent Column Mapping.
     * Keys are the real names in the table and the values their names in the application
     *
     * @return array
     */
    public function columnMap()
    {
        return array(
            'id'      => 'id',
            'addtime' => 'addtime',
            'uptime'  => 'uptime',
            'delsign' => 'delsign',
            'descr'   => 'descr',
            'title'   => 'title',
            'key'     => 'key',
            'value'   => 'value',
            'valtype' => 'valtype',
            'kind'    => 'kind'
        );
    }

    public function initialize()
    {
        $this->useDynamicUpdate( true );

        $this->addBehavior( new SoftDelete( array(
            'field' => 'delsign',
            'value' => SystemEnums::DELSIGN_YES,
        ) ) );
        $this->setSource( $this->di[ 'config' ][ 'database' ][ 'prefix' ] . $this->getSource() );
    }

}
